﻿using System.Text;
using API.Helpers;

namespace POS.API.Helpers
{
    public static class ClaimsHelper
    {
        private static readonly IClaimsManager ClaimsManager;

        static ClaimsHelper()
        {
            ClaimsManager = DependencyInjectionHelper.Resolve<IClaimsManager>(typeof(ClaimsIdentityManager));
        }

        public static bool Exists(string key)
        {
            return ClaimsManager.Exists(key);
        }

        public static void AddClaim(string key, object value)
        {
            ClaimsManager.AddClaim(key, value);
        }

        public static void AddClaim(string key, string value)
        {
            ClaimsManager.AddClaim(key, value);
        }

        public static void RemoveClaim(string key)
        {
            ClaimsManager.RemoveClaim(key);
        }

        public static T RetrieveClaim<T>(string key)
        {
            return ClaimsManager.RetrieveClaim<T>(key);
        }
    }

    public interface IClaimsManager
    {
        bool Exists(string key);
        void AddClaim(string key, object value);
        void AddClaim(string key, string value);
        void RemoveClaim(string key);
        T RetrieveClaim<T>(string key);
    }
}
